package edu.xcdq.util;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class ConfigManager {
    private  static  ConfigManager configManager = null;
    private static Properties properties = null;
    // 1 私有化构造方法
    private ConfigManager() {
        properties = new Properties();
        InputStream in = ConfigManager.class.getClassLoader().getResourceAsStream("database.properties");
        try {
            properties.load(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    // 2 返回对象
    public static ConfigManager getInstance() {
        if (configManager == null ) {
            configManager = new ConfigManager();
        }
        return configManager;
    }

    public String getString(String key) {
        return properties.getProperty(key);
    }

}
